home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-13 | 10.1 KB | 547 lines | [TEXT/MPS ] |
- /*------------------------------------------------------------------------------
-
- File: TextEditor.cpp
-
- Written by: Steve Smith
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
- Description: TextEditor demonstrates a fully functional embedding
- styled text editor. etc....
-
- The implementation is divided into protocols with
- one file per protocol. This will hopefully make it
- easier to get around.
-
-
- Demonstrates: The following recipes were used in implementing the
- TextEditor:
- 1. Open
- 2. Adding A Display Frame
- 3. Adding A Facet
- 4. Part Drawing
- 5. Refcounting Geometry
- 6. ViewTypes & Presentations
- 7. Display Frame 'ternalization
- 8. Part Init & Externalization
- 9. Part Init & partWrapper
- 10. Part Storage Model
- 11. Persistent Reference
- 12. RefCounting
- 13. Storage Unit
- 14. Activation
- 15. Basic Event Handling
- 16. Menus
- 17. Windows & Dialogs
- 18. Exception Handling
- 19. Memory Manager
- 20. Using Resources
-
-
- Notes: • The SOM_CATCH macro acts as an umbrella exception
- "catcher" for the entire method. If at any point an
- exception is thrown, the exception value (Error Code) is
- stuffed into the 'ev' parameter passed into the method and
- the code following the macro is executed.
-
- • For methods where it is necessary to call the parent class
- implementation, the calls are made from the SOM class. See
- som_SamplePart.cpp and the Class Reference to know whether
- you need to call the parent class from any method.
-
-
- Known Problems: <none>
-
- ------------------------------------------------------------------------------*/
-
-
- // -- Compiler/Preprocessor Notification --
-
- // Notification that this is a SOM source file
- #define SampleCode_TextEditor_Class_Source
- // define underscore (_) field names
- #define VARIABLE_MACROS
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _EXCEPT_
- #include "Except.h"
- #endif
-
- // -- TextEditor Includes
-
- #ifndef _TEXTEDITORGLOBALS_
- #include "TextEditorGlobals.h"
- #endif
-
- #ifndef SOM_SampleCode_TextEditor_xih
- #include "TextEditor.xih"
- #endif
-
- #ifndef _TEXTEDITORDEF_
- #include "TextEditorDef.h"
- #endif
-
- #ifndef _TEXTEDITORUTILS_
- #include "TextEditorUtils.h"
- #endif
-
- #ifndef _VALUESTREAM_
- #include "ValueStream.h"
- #endif
-
- #ifndef _PARTRUN_
- #include "PartRun.h"
- #endif
-
- #ifndef _STDTEXTPROPERTIES_
- #include "StdTextProps.h"
- #endif
-
- #ifndef _TEXTEDITORPREFS_
- #include "TextEditorPrefs.h"
- #endif
-
- #ifndef _TEXTEDITORSETTINGS_
- #include "TextEditorSettings.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODSemanticInterface_xh
- #include <SemtIntB.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODFrameFacetIterator_xh
- #include <FrFaItr.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Foci_defined
- #include <Foci.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef _STDDEFS_
- #include <StdDefs.h>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- #ifndef SOM_ODTranslation_xh
- #include "Translt.xh"
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_ODDragAndDrop_xh
- #include <DragDrp.xh>
- #endif
-
- #ifndef SOM_ODDragItemIterator_xh
- #include <DgItmIt.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODFocusSet_xh
- #include <FocusSet.xh>
- #endif
-
- #ifndef SOM_ODMenuBar_xh
- #include <MenuBar.xh>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODWindowState_xh
- #include <WinStat.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODSemanticInterface_xh
- #include <SemtIntf.xh>
- #endif
-
- #ifndef SOM_ODTypeList_xh
- #include <TypeList.xh>
- #endif
-
- #ifndef SOM_ODTypeListIterator_xh
- #include <TypLsItr.xh>
- #endif
-
-
- // -- OpenDoc Utilities --
-
- #ifndef _ODDEBUG_
- #include <ODDebug.h>
- #endif
-
- #ifndef _ALTPOINT_
- #include <AltPoint.h>
- #endif
-
- #ifndef _BARRAY_
- #include <BArray.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifndef _USERSRCM_
- #include <UseRsrcM.h>
- #endif
-
- #ifndef _FOCUSLIB_
- #include <FocusLib.h>
- #endif
-
- #ifndef _ISOSTR_
- #include <ISOStr.h>
- #endif
-
- #ifndef _POUTILS_
- #include <POUtils.h>
- #endif
-
- // -- Macintosh Includes --
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifndef __DRAG__
- #include <Drag.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __CONTROLS__
- #include <Controls.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __ICONS__
- #include <Icons.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __PRINTING__
- #include <Printing.h>
- #endif
-
- #ifndef __LOWMEM__
- #include <LowMem.h>
- #endif
-
- #ifndef mathRoutinesIncludes
- #include <math routines.h>
- #endif
-
- // -- Textension Includes --
-
- #ifndef _Textension_
- #include "Textension.h"
- #endif
-
- #ifndef _QDTextRun_
- #include "QDTextRun.h"
- #endif
-
- #ifndef _AdvancedRuler_
- #include "AdvancedRuler.h"
- #endif
-
- #ifndef _RunObject_
- #include "RunObject.h"
- #endif
-
- #ifndef _LinkedFrames_
- #include "LinkedFrames.h"
- #endif
-
- #ifndef _AttrObject_
- #include "AttrObject.h"
- #endif
-
- #ifndef _FileStream_
- #include "FileStream.h"
- #endif
-
- //#ifndef _RulerUI_
- //#include "RulerUI.h"
- //#endif
-
-
- #include "TextEditorInitialize.cpp"
- //==============================================//
- // Protocol: Initialization
- //
- // Methods: Constructor
- // Destructor
- // InitPart
- // InitPartFromStorage
- // Initialize
- // StartTextension
- // InitializeTextension
- // LoadMenus
- //==============================================//
-
- #include "TextEditorStorage.cpp"
- //==============================================//
- // Protocol: Storage
- //
- // Methods: Release
- // ReleaseAll
- // Purge
- // InternalizeStateInfo
- // InternalizeContent
- // Externalize
- // ExternalizeStateInfo
- // ExternalizeContent
- // CleanseContentProperty
- // CheckAndAddProperties
- // SetDirty
- // ReadPartInfo
- // WritePartInfo
- // ClonePartInfo
- // SUHasValidData
- // StreamDataOut
- // StreamDataIn
- // ExternalizeKinds
- // ChangeKind
- //==============================================//
-
- #include "TextEditorLayout.cpp"
- //==============================================//
- // Protocol: Layout
- //
- // Methods: DisplayFrameAdded
- // DisplayFrameConnected
- // DisplayFrameRemoved
- // DisplayFrameClosed
- // AttachSourceFrame
- // ViewTypeChanged
- // CalcNewUsedShape
- // UpdateFrame
- // FrameShapeChanged
- // Open
- // GetFramesWindow
- // CreateWindow
- // GetDefaultWindowProperties
- // GetSavedWindowProperties
- // CalcPartWindowSize
- // CalcPartWindowPosition
- // GetActiveFacetForFrame
- // SequenceChanged
- // RequestEmbeddedFrame
- // RemoveEmbeddedFrame
- // RequestFrameShape
- // UsedShapeChanged
- // AdjustBorderShape
- //==============================================//
-
- #include "TextEditorImaging.cpp"
- //==============================================//
- // Protocol: Imaging
- //
- // Methods: GenerateThumbnail
- // FacetAdded
- // FacetRemoved
- // Draw
- // DrawFrameView
- // DrawPageBounds
- // DrawIconView
- // DrawThumbnailView
- // GeometryChanged
- // HilightChanged
- // CalcViewRect
- // CalcTextBounds
- // AdjustScrollbars
- // CalcSelectionRgn
- // PresentationChanged
- // RepositionScrollbars
- // CanvasChanged
- // CanvasUpdated
- // GetPrintResolution
- //==============================================//
-
- #include "TextEditorActivation.cpp"
- //==============================================//
- // Protocol: Activation
- //
- // Methods: BeginRelinquishFocus
- // CommitRelinquishFocus
- // AbortRelinquishFocus
- // FocusAcquired
- // FocusLost
- // ActivateFrame
- // ActivateTextension
- // ActivateScrollbars
- // WindowActivating
- //==============================================//
-
- //#include "TextEditorEvents.cpp"
- //==============================================//
- // Protocol: Event Handling
- //
- // Methods: AdjustMenus
- // AdjustEditMenu
- // AdjustTextEditorMenus
- // SetMenuItem
- // AdjustDynamicMenuItems
- // HandleEvent
- // HandleMenuEvent
- // HandleWindowEvent
- // HandleKeyboardEvent
- // HandleMouseEvent
- // MouseEnter
- // MouseWithin
- // MouseLeave
- // DragEnter
- // DragWithin
- // DragLeave
- // Drop
- // UndoAction
- // RedoAction
- // DisposeActionState
- // ReadActionState
- // WriteActionState
- // DoMouseEvent
- // DoScrollDocument
- // DoDragSelection
- // DoCut
- // DoCopy
- // DoPaste
- // DoPasteAs
- // DoClear
- // DoSelectAll
- // DoOpenSelection
- // DoInsert
- // DoPageSetup
- // DoPrint
- // DoUndo
- // DoPartInfo
- // DoPreferences
- // ShowHideRuler
- // DoSettings
- // RealFontSizeMenu
- // DoTextStyling
- // DoOtherFontSize
- // DoIdle
- // DoAboutBox
- //==============================================//
-
- #include "TextEditorEmbedding.cpp"
- //==============================================//
- // Protocol: Embedding
- //
- // Methods: EmbedForeignContent
- // AddEmbeddedFacet
- // CreateEmbeddedRunObject
- // ContainingPartPropertiesChanged
- // GetContainingPartProperties
- // RevealFrame
- // EmbeddedFrameSpec
- // CreateEmbeddedFramesIterator
- //==============================================//
-
- #include "TextEditorLinking.cpp"
- //==============================================//
- // Protocol: Linking
- //
- // Methods: CreateLink
- // LinkUpdated
- // RevealLink
- // EmbeddedFrameChanged
- // LinkStatusChanged
- //
- //==============================================//
-